$(function() {
    init_vue();
});

function init_vue() {
    var vue = new Vue({
        el : "#myapp",
        data : {
            startRow : 0,
            endRow : 0,
            total : 0,
            firstPage : 0,
            lastPage : 0,
            pageNum : 1,
            pageSize : 15,
            list : null,
            setting : null,
            navigatepageNums : null
        },
        events : {},
        methods : {
            init : function() {
                close_layuiLayerLoad();
                this.getData();
            },
            showPage : function(page) {
                // alert(page);
                this.pageNum = page;
                this.getData();
            },
            getData : function() {
                showLoad();
                var t = this;
                postMsg(root+"/organization/toAuditRechargeOrWithdrawals", {
                    page_num : t.pageNum,
                    page_size : t.pageSize,
                }, function(i) {
                    t.list = null;
                    t.list = i.data.list;
                    t.setting = i.data.setting;
                    t.startRow = i.data.startRow;
                    t.endRow = i.data.endRow;
                    t.total = i.data.total;
                    t.firstPage = i.data.firstPage;
                    t.lastPage = i.data.lastPage;
                    t.navigatepageNums = i.data.navigatepageNums;
                    hideLoad();
                });
            },
            audit: function (id, audit_state, type) {
                var t = this;
                if (audit_state == 1) {
                    if (type == 1) {
                        layer.confirm('请确认对方资金是否已入账', {
                            btn: ['已确认入账','在检查一下', '取消'] //按钮
                            ,closeBtn: 0
                        }, function(index){
                            layer.close(index);
                            t.subAudit(id, audit_state, 0);
                        });
                    } else {
                        layer.confirm('出金申请已通过后，是否进行第三方代付', {
                            btn: ['第三方代付','手动银行转帐', '取消'] //按钮
                            ,closeBtn: 0
                        }, function(index){
                            layer.close(index);
                            // aaa(id, state, obj, 1);
                            // layer.alert("功能暂不能用");
                            t.subAudit(id, audit_state, 1);
                        }, function(){
                            t.subAudit(id, audit_state, 0);
                            // aaa(id, state, obj, 0);
                        });
                    }
                } else {
                    var msg = "确定要拒绝该入金申请吗";
                    if (type == 2) {
                        msg = "确定要拒绝该出金申请吗";
                    }
                    layer.confirm(msg, {
                        btn: ['确定','取消'] //按钮
                        ,closeBtn: 0
                    }, function(index){
                        layer.close(index);
                        // aaa(id, state, obj, 1);
                        // layer.alert("功能暂不能用");
                        t.subAudit(id, audit_state, 0);
                    });
                }
            },
            subAudit: function (id, audit_state, auto) {
                postMsg(root+"/organization/subAuditRechargeOrWithdrawals", {
                    id : id,
                    audit_state : audit_state,
                    auto:auto
                }, function(i) {
                    if (i.code == 1) {
                        $.scojs_message('操作成功', $.scojs_message.TYPE_OK);
                    } else {
                        $.scojs_message('操作失败', $.scojs_message.TYPE_ERROR);
                    }
                });
            }
        }
    });
    vue.init();
}